<template>
	<div style="display: flex; justify-content: space-between;">
		<h3 style="width: 30%;"></h3>
		<h3 align="center">管理员 -【 教师管理 】</h3>
		<h4 style="width: 30%;">
			<button @click="go2Add()">添加教师</button>
		</h4>
	</div>
	<hr />
	<div>
		<table style="width: 90%;line-height: 36px;">
			<tr>
				<td>ID</td>
				<td>姓名</td>
				<td>手机号</td>
				<td>头像</td>
				<td>修改</td>
				<td>删除</td>
			</tr>
			<tr v-for="t in teas">
				<td>{{t.uid}}</td>
				<td>{{t.uname}}</td>
				<td>{{t.phone}}</td>
				<td>
					<img v-bind:src="`${$ip}/api/public/showimg/${t.pic}`"
					style="width: 5vw;height: 5vw">
				</td>
				<td><button @click="go2Update(t.uid)">upd</button></td>
				<td><button @click="doDel(t.uid)">del</button></td>
			</tr>
		</table>
	</div>
</template>

<script setup>
	import axios from 'axios';
</script>
<script>
	export default{
		data(){
			return{
				teas :[],
				tea :{},
				
			}
		},
		methods:{
			doDel(uid){
				console.log("教师删除");
				
				this.$get("/api/adm/tea/del?uid="+uid
				).then((resp)=>{
					console.log(resp.data.data);
					this.teas = resp.data.data;
					this.$store.state.erropen = true;
					this.$store.state.errmsg = "删除成功";
				})
			},
			go2Update(uid){
				console.log("去学生添加")
				this.$router.push({
					path:'/adm/teaAdd',
					query:{id:uid}
				});
			},
			go2Add(){
				console.log("去学生添加")
				this.$router.push({
					path:'/adm/teaAdd',
					query:{id:0}
				});
			},
			findAll(){
				console.log("学生准备显示");
				
				this.$get(this.$ip+"/api/adm/tea/findAll"
				).then((resp)=>{
					console.log(resp.data.data);
					this.teas = resp.data.data;
				})
			},
		},
		mounted() {
			console.log("初始化加载数据....");
			this.findAll();
		},
}
</script>

<style>
</style>
